package com.zhangck.webDao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import cn.itcast.crm.domain.Customer;

/** 
* @author 上午茶
* @version 创建时间：2018年6月2日 下午12:36:51 
* 类说明 
*/
public interface CustomerRepository extends JpaRepository<Customer, Integer> {

	
	public List<Customer> findByFixedAreaIdIsNull();
	
	public List<Customer> findByFixedAreaId(String fixedAreaId);
	
	@Query(value="select * from T_CUSTOMER t where c_telephone =?",nativeQuery= true)
	public Customer getTelephone(String Telephone);

	@Query("update Customer set type=1 where telephone= ?")
	@Modifying
	@Transactional
	public void updateTelephone(String Telephone);
	
	@Query(value="select * from T_CUSTOMER where c_password =?2 and c_telephone=?1",nativeQuery=true)
	public Customer findByTelephoneAndPass(String telephone, String password);

	@Query("select fixedAreaId from Customer where address=?")
	public String findFixedAreaIdByAddress(String address);
}
